<!-- saved from url=(0014)about:internet -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>HaikuBox.as</title>
<link rel="stylesheet" type="text/css" href="../../../../../SourceStyles.css"/>
</head>

<body><pre><span class="ActionScriptpackage">package</span> <span class="ActionScriptDefault_Text">net</span>.<span class="ActionScriptDefault_Text">whatmark</span>.<span class="ActionScriptDefault_Text">playavillain</span>.<span class="ActionScriptDefault_Text">component</span>
<span class="ActionScriptBracket/Brace">{</span>

    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span>.<span class="ActionScriptDefault_Text">display</span>.<span class="ActionScriptOperator">*</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span>.<span class="ActionScriptDefault_Text">filters</span>.<span class="ActionScriptDefault_Text">DropShadowFilter</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span>.<span class="ActionScriptDefault_Text">text</span>.<span class="ActionScriptDefault_Text">engine</span>.<span class="ActionScriptOperator">*</span>;
    
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span>.<span class="ActionScriptDefault_Text">containers</span>.<span class="ActionScriptDefault_Text">Canvas</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span>.<span class="ActionScriptDefault_Text">core</span>.<span class="ActionScriptDefault_Text">UIComponent</span>;

    <span class="ActionScriptReserved">public</span> <span class="ActionScriptclass">class</span> <span class="ActionScriptDefault_Text">HaikuBox</span> <span class="ActionScriptReserved">extends</span> <span class="ActionScriptDefault_Text">Canvas</span> <span class="ActionScriptBracket/Brace">{</span>

        <span class="ActionScriptReserved">public</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">go1</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>;
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">shichi</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>;
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">go2</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>;
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">haijin</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>;    
        
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">margin</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 10;
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">haijinMargin</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 10;        
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">defaultHaikuFontSize</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 40;
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">defaultHaijinFontSize</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 30;
        
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">textColor</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">uint</span> <span class="ActionScriptOperator">=</span> 0<span class="ActionScriptDefault_Text">x000000</span>;
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">font</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">FontDescription</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">FontDescription</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptString">&quot;IPAMINCHO&quot;</span><span class="ActionScriptBracket/Brace">)</span>;

        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">showHaiku</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span><span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptDefault_Text">removeAllChildren</span><span class="ActionScriptBracket/Brace">()</span>;
            <span class="ActionScriptDefault_Text">createLineComponent</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">defaultHaikuFontSize</span>,<span class="ActionScriptDefault_Text">go1</span>,<span class="ActionScriptDefault_Text">defaultHaikuFontSize</span><span class="ActionScriptOperator">*</span>3<span class="ActionScriptOperator">+</span><span class="ActionScriptDefault_Text">margin</span><span class="ActionScriptOperator">*</span>3<span class="ActionScriptOperator">+</span><span class="ActionScriptDefault_Text">haijinMargin</span>,10<span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">createLineComponent</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">defaultHaikuFontSize</span>,<span class="ActionScriptDefault_Text">shichi</span>,<span class="ActionScriptDefault_Text">defaultHaikuFontSize</span><span class="ActionScriptOperator">*</span>2<span class="ActionScriptOperator">+</span><span class="ActionScriptDefault_Text">margin</span><span class="ActionScriptOperator">*</span>2<span class="ActionScriptOperator">+</span><span class="ActionScriptDefault_Text">haijinMargin</span>,10<span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">createLineComponent</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">defaultHaikuFontSize</span>,<span class="ActionScriptDefault_Text">go2</span>,<span class="ActionScriptDefault_Text">defaultHaikuFontSize</span><span class="ActionScriptOperator">+</span><span class="ActionScriptDefault_Text">margin</span><span class="ActionScriptOperator">+</span><span class="ActionScriptDefault_Text">haijinMargin</span>,10<span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">createLineComponent</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">defaultHaijinFontSize</span>,<span class="ActionScriptDefault_Text">haijin</span>,10,<span class="ActionScriptDefault_Text">defaultHaikuFontSize</span><span class="ActionScriptOperator">*</span>6<span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">createLineComponent</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">defaultFontSize</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span>,<span class="ActionScriptDefault_Text">txt</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>,<span class="ActionScriptDefault_Text">x</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span>,<span class="ActionScriptDefault_Text">y</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span><span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">if</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">txt</span> <span class="ActionScriptOperator">==</span> <span class="ActionScriptReserved">null</span><span class="ActionScriptBracket/Brace">){</span>
                <span class="ActionScriptReserved">return</span>;
            <span class="ActionScriptBracket/Brace">}</span>
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">fontSize</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">Math</span>.<span class="ActionScriptDefault_Text">min</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">defaultFontSize</span>,<span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">height</span><span class="ActionScriptOperator">-</span><span class="ActionScriptDefault_Text">y</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">/</span><span class="ActionScriptDefault_Text">txt</span>.<span class="ActionScriptDefault_Text">length</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">format</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">ElementFormat</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">ElementFormat</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptDefault_Text">font</span>, <span class="ActionScriptDefault_Text">fontSize</span>,<span class="ActionScriptDefault_Text">textColor</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">format</span>.<span class="ActionScriptDefault_Text">locale</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">&quot;ja&quot;</span>;
            
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">textBlock</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">TextBlock</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">TextBlock</span><span class="ActionScriptBracket/Brace">()</span>;
            <span class="ActionScriptDefault_Text">textBlock</span>.<span class="ActionScriptDefault_Text">lineRotation</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">TextRotation</span>.<span class="ActionScriptDefault_Text">ROTATE_90</span>;
            <span class="ActionScriptDefault_Text">textBlock</span>.<span class="ActionScriptDefault_Text">textJustifier</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">EastAsianJustifier</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptString">&quot;ja&quot;</span>, <span class="ActionScriptDefault_Text">LineJustification</span>.<span class="ActionScriptDefault_Text">UNJUSTIFIED</span> <span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">textBlock</span>.<span class="ActionScriptDefault_Text">content</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">TextElement</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptDefault_Text">txt</span>, <span class="ActionScriptDefault_Text">format</span> <span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">textLine</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">TextLine</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">textBlock</span>.<span class="ActionScriptDefault_Text">createTextLine</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptReserved">null</span>, <span class="ActionScriptDefault_Text">height</span> <span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptReserved">if</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">textLine</span> <span class="ActionScriptOperator">!=</span> <span class="ActionScriptReserved">null</span><span class="ActionScriptBracket/Brace">){</span>
                <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">comp</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">UIComponent</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">UIComponent</span><span class="ActionScriptBracket/Brace">()</span>;
                <span class="ActionScriptDefault_Text">comp</span>.<span class="ActionScriptDefault_Text">width</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">fontSize</span>;
                <span class="ActionScriptDefault_Text">comp</span>.<span class="ActionScriptDefault_Text">height</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">textLine</span>.<span class="ActionScriptDefault_Text">height</span>;
                <span class="ActionScriptDefault_Text">comp</span>.<span class="ActionScriptDefault_Text">x</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">x</span>;
                <span class="ActionScriptDefault_Text">comp</span>.<span class="ActionScriptDefault_Text">y</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">y</span>;
                <span class="ActionScriptDefault_Text">comp</span>.<span class="ActionScriptDefault_Text">addChild</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptDefault_Text">textLine</span> <span class="ActionScriptBracket/Brace">)</span>;
                <span class="ActionScriptDefault_Text">addChild</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">comp</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptBracket/Brace">}</span>            
        <span class="ActionScriptBracket/Brace">}</span>

    <span class="ActionScriptBracket/Brace">}</span>

<span class="ActionScriptBracket/Brace">}</span></pre></body>
</html>
